home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Think Class Libraries / CPrefsFile & Friends 1.0 / COOPrefs.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-30  |  2.1 KB  |  113 lines  |  [TEXT/KAHL]

  1. /*
  2.  * COOPrefs.c
  3.  * A sample subclass of CPrefsFile.
  4.  *
  5.  * by Jamie McCarthy
  6.  * Internet: k044477@kzoo.edu            AppleLink: j.mccarthy
  7.  * Telephone:  800-421-4157 or US 616-665-7075 (9:00-5:00 Eastern time)
  8.  *
  9.  * This subclass of CPrefsFile stores the preferences handle in a
  10.  * protected class variable, only making the class itself available to
  11.  * the rest of the program.  The preferences data can only be accessed
  12.  * through access methods.
  13.  *
  14.  * The disadvantage of this method is that it requires a lot of extra
  15.  * typing and a little extra object code.
  16.  *
  17.  * The advantage of this method is that it provides a consistent
  18.  * interface to the data that won't change if you change how it's
  19.  * stored.  It's just generally cleaner.
  20.  *
  21.  * This file and its header file also demonstrate how to declare a
  22.  * constant class variable:  itsFileType.  It's cleaner than a #define,
  23.  * works on any data type you like, and doesn't make object code.
  24.  *
  25.  */
  26.  
  27.  
  28.  
  29. /********************************/
  30.  
  31. #include "COOPrefs.h"
  32.  
  33. /********************************/
  34.  
  35. #include <TBUtilities.h>
  36.  
  37. /********************************/
  38.  
  39. #define ooStrsID (1024)
  40.  
  41. /********************************/
  42.  
  43. COOPrefs *gOOPrefs;
  44.  
  45. /********************************/
  46.  
  47.  
  48.  
  49. const OSType COOPrefs::itsFileType = 'PREF';
  50.  
  51.  
  52.  
  53. void COOPrefs::ILaconicPrefs(void)
  54. {
  55.     inherited::IPrefsFile(ooStrsID, this->itsFileType, TRUE);
  56. }
  57.  
  58.  
  59.  
  60. void COOPrefs::assignToPrefsHndl(Handle theHandle)
  61. {
  62.     itsPrefsHndl = (laconicPrefsHndl) theHandle;
  63. }
  64.  
  65.  
  66.  
  67. Handle COOPrefs::valueOfPrefsHndl(void)
  68. {
  69.     return (Handle) itsPrefsHndl;
  70. }
  71.  
  72.  
  73.  
  74. short COOPrefs::sizeOfPrefs(void)
  75. {
  76.     return sizeof(laconicPrefs);
  77. }
  78.  
  79.  
  80.  
  81. Boolean COOPrefs::getDefaultOverwriteExistingFiles(void)
  82. {
  83.     return (**itsPrefsHndl).defaultOverwriteExistingFiles != 0;
  84. }
  85.  
  86.  
  87.  
  88. short COOPrefs::getSleepTime(void)
  89. {
  90.     return (**itsPrefsHndl).sleepTime;
  91. }
  92.  
  93.  
  94.  
  95. short COOPrefs::getUpdateTicks(void)
  96. {
  97.     return (**itsPrefsHndl).updateTicks;
  98. }
  99.  
  100.  
  101.  
  102. void COOPrefs::getFontSize(short *theFontSize)
  103. {
  104.     *theFontSize = (**itsPrefsHndl).fontSize;
  105. }
  106.  
  107.  
  108.  
  109. void COOPrefs::getFontName(Str63 theFontName)
  110. {
  111.     CopyPString( (**itsPrefsHndl).fontName, theFontName );
  112. }
  113.